﻿package com.PlantVsZombies.Zombies;

import java.awt.Graphics;

import com.PlantVsZombies.common.Life;
import com.PlantVsZombies.util.ImageUtil;

public class Star extends Life{
	int x;
	int y;
	int type;
	public boolean isLive = true;
	int move = 1;
	int move0 = 1;
	
	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public boolean getLive() {
		return isLive;
	}
	public void setLive(boolean isLive) {
		this.isLive = isLive;
	}
	public Star(int x,int y,int type){
		this.x = x;
		this.y = y;
		this.type = type;
	}
	public void drawMe(Graphics g){
		if(type == 0){
			g.drawImage(ImageUtil.star1.getImage(), x, y,null);
		}
		else if(type == 1){
			g.drawImage(ImageUtil.star2.getImage(), x, y,null);
		}else
			g.drawImage(ImageUtil.star3.getImage(), x, y,50,50,null);
	}
	public void move(){
		this.x -= 1;
		this.y -= move0;
		if (this.y < 20) {
			move0 = -move0;
		}
		if (this.y > 450)
			move0 = -move0;
	}
	@Override
	public int doRun() {
		this.move();

		try {
			Thread.sleep(30);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		if (this.x < 0 || this.y<0 || this.y >600) {
			this.isLive = false;
			return 0;
		}
		return 1;
	}
}